Class name is rule id #212
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR updates how rule id attributes are handled in the pypanther framework. Previously, the framework required explicit setting of the id attribute and would fail validation if it was missing. Now, the id is automatically set to the class name in init_subclass if not explicitly defined.
Key changes:
Modified init_subclass to set id to the class name if not explicitly defined
Updated validation logic to reflect this new behavior
Updated test cases to verify the automatic id assignment
This change reduces boilerplate code by eliminating the need to explicitly set id = "ClassName" in every rule class, while maintaining backward compatibility with rules that do explicitly set their IDs.
References
N/A
Checklist
[x] Added unit tests
Updated test_rule_missing_id to test_rule_id_is_class_name to verify automatic ID assignment
Test verifies that id is correctly set to class name when not explicitly defined
[x] Tested end to end
Verified existing rules continue to work with both explicit and implicit IDs